#!/usr/bin/perl #Change this to your path to perl # AceWhois Copyright Neil Hallam $version = "AceWhois 1.07.02"; # 05-August-2002 # This script is freeware but please make sure you read the terms # and conditions for this script at http://www.web-shack.net/products/acewhois/licence.html # You may *not* remove the powered by link unless you Send me a gift # visit http://web-shack.net/products/acewhois/reg.html to find out more. # Any problems with running this script then please seek assistance in our # online forum http://web-shack.net/cgi-bin/forum/ikonboard.cgi $showdetail ="yes"; $submit_button_text ="Do the search"; $default_search_text = "your-name"; $filename = "whois.html"; $availabletext="is available"; $unavailabletext="is unavailable"; #################################### # Any changes below are unsupported. #################################### use CGI; $query = new CGI; use Socket; print $query->header; $pathtoscript = $0; $scriptname = "whois.pl"; $pathtoscript =~s/$scriptname//g; @tlds_db =(); @server_db =(); $results = ""; $error = ""; if ($query->param('debug') eq "password") { &debug; } open (TLD,"$pathtoscript" . "tlds.txt") or &ohdear("Cannot open $pathtoscript". "tlds\.txt"); @TLDS = ; close(TLD); foreach $xxx (@TLDS) { if ($xxx !~ /^\#/) { @xxxx = split(/\|/, $xxx); @tlds_db = (@tlds_db,$xxxx[0]); @server_db = (@server_db,$xxxx[1]); @match_db = (@match_db,$xxxx[2]); } } open(HTMLFILE,"$pathtoscript" . "$filename") or &ohdear("Cannot open $pathtoscript$filename"); { local $/; $htmlContent = } close(HTMLFILE); if ($htmlContent =~ /\*\*dropdown\*\*/) { $dropdownlist = "/; $htmlContent =~ s/\*\*submit\*\*/<\/form>/; $htmlContent =~ s/\*\*dropdown\*\*/$dropdownlist/; if( $query->param('fqdn') eq "" ) { &print_html; } $server = @server_db[$index]; chomp($server); $idomain = $query->param('fqdn'); $idomain=~ s/^http\:\/\///; #Remove http://. $idomain=~ s/^www\.//; #Remove www. if( $query->param('tld') ne "" ) { $domainname = $idomain; $tld=$query->param('tld'); } else { @splitdomain = split(/\./, $idomain , 2); $domainname = $splitdomain[0]; $tld = "." . $splitdomain[1]; if ($tld eq ".") { $tld = $tlds_db[0]; } } $count = 0; foreach $x (@tlds_db) { if ($tld eq $x){$index=$count;last;} $count++; } $domainname =~s/^\s+|\s*\n$//g; $domainname=~tr/A-Z/a-z/; $domainname=~s/[^a-z0-9\-]//g; $domainname=~s/^\-//; $domainname=~s/\-$//; if( $domainname eq "" ) { &print_html; } $server = @server_db[$index]; chomp($server); $fqdn = $domainname . $tld; &checkdomain; if ($showdetail eq "yes") { $results = $results . $out; } &print_html; exit; sub checkdomain { $port = getservbyname('whois','tcp'); $iaddr = inet_aton($server) || die &ohdear("Error No Such Host: $server"); $paddr = sockaddr_in($port, $iaddr); $proto = getprotobyname('tcp'); socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die &ohdear("socket: $!"); connect(SOCK, $paddr) || die &ohdear(" $! $server"); select SOCK; $| = 1; print SOCK "$fqdn\015\012"; select STDOUT; while($line = ) { if ($line =~ /@match_db[$index]/i) { $available="yes"; } $out = $out . $line . "
\r"; if ($line =~ /Whois Server: whois./) { $server =$line; $server =~s/Whois Server: //; $server =~ s/^\s+|\s*\n$//g; $out = $out . "

**Going to $server for full record.**

"; &checkdomain; } } close (SOCK); if ($available eq "yes") { $results = "

$fqdn $availabletext

"; } else { $results = "

$fqdn $unavailabletext

"; } } sub print_html { $results = $results . "

Powered by AceWhois

"; $htmlContent =~ s/\*\*results\*\*/$results/; print "$htmlContent"; exit; } sub ohdear { print<<"STUFF"; $out An Error Has Occured: $_[0] STUFF exit; } ######### sub debug { print<<"HTML"; This is $version HTML print "

"; print "The path for this file is $0"; print "
"; print "
DOCUMENT_ROOT is $ENV{'DOCUMENT_ROOT'}
\n"; foreach $key (keys(%ENV)) { print"$key = $ENV{$key}
\n"; } @dir_list = @INC; $i = 0; while ($i <= $#dir_list) { $dir = $dir_list[$i]; &check_dir($dir); $i++; } print "
"; exit; #endsub } sub check_dir { my($dir) = $_[0]; my(@list); my($new_dir); my($filename); if ($dir eq ".") { return; } chdir( $dir ); @list = glob("\*"); foreach $filename (@list) { if ($filename =~ /pm$/ ) { print "$dir/$filename
\n"; } # Check if is directory. if ( -d $filename ) { $new_dir = $dir . "/" . $filename; # Append directory name onto dir list. $pos = $#dir_list + 1; $dir_list[$pos] = $new_dir; } } }